package com.changpay.zywy.adapter

import android.content.Context
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.changpay.zywy.R
import com.changpay.zywy.bean.RankBean


/**
 * Created by chenxz on 2018/4/22.
 */
class RankAdapter(private val context: Context?, datas: MutableList<RankBean.ListBean>) :
    BaseMultiItemQuickAdapter<RankBean.ListBean, BaseViewHolder>(datas) {

    init {
        addItemType(1, R.layout.item_rank)
        addItemType(2, R.layout.item_rank_two)
    }

    override fun convert(helper: BaseViewHolder?, item: RankBean.ListBean) {
        item ?: return
        helper ?: return
        when (helper.itemViewType) {
            1 -> {
                helper.setText(R.id.tv_rum, item.rownum.toString()).setText(
                    R.id.tv_phone,
                    item.lg_member_name?.replace("(\\d{3})\\d{4}(\\d{4})", "$1****$2").toString()
                ).setText(R.id.tv_number, item.amount.toString())
            }
            2 -> {
                helper.setText(R.id.tv_rum, item.rownum.toString()).setText(
                    R.id.tv_phone,
                    item.lg_member_name?.replace("(\\d{3})\\d{4}(\\d{4})", "$1****$2").toString()
                ).setText(R.id.tv_number, item.amount.toString())
            }
        }
    }

}
